import { ApiCall } from "tsrpc";
import { player } from "../../../model/fight/body/player";
import { api_Skills, ReqSkills, ResSkills } from "../../../shared/master/body/PtlSkills";

export default async function (call: ApiCall<ReqSkills, ResSkills>) {
    let user = call.req._player as player;
    /**
     * 技能名称
     * 技能等级
     * 技能来源 装备
     */
    let reqList: api_Skills[] = [];
    let sk_body = user.getSkill_body();
    let sk_equip = user.getSkill_equip();
    let idx = 0;
    for (let i = 0; i < sk_body.length; i++) {
        const element = sk_body[i];
        reqList.push({
            idx: idx,
            name: element.rename,
            leve: element.leve.num,
            cd:element.getCdTime(),
            from: ''
        })
        idx += 1;
    }

    // 装备附带技能
    for (let i = 0; i < sk_equip.length; i++) {
        const element = sk_equip[i];
        reqList.push({
            idx: idx,
            name: element.rename,
            leve: element.leve.num,
            cd:element.getCdTime(),
            from: `装备`
        })
        idx += 1;
    }
    call.succ({ skList: reqList })
}